package org.jeecg.common.util;

import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;

/**
 * @author xiebin
 * @version 1.0V
 * @Title: SysUtil
 * @ProjectName newics
 * @Description: TODO
 * @date 2020/3/1014:36
 */
public class SysUtil {
    /**
     *
     * 功能描述: 获取User
     *
     * @param:
     * @return: 
     * @auther: Administrator
     * @date: 2020/3/10 14:36
     */
    public static LoginUser getUserInfo() {
        LoginUser sysUser = null;
        try {
            sysUser = SecurityUtils.getSubject().getPrincipal() != null ? (LoginUser) SecurityUtils.getSubject().getPrincipal() : null;
        } catch (Exception e) {
            //e.printStackTrace();
            sysUser = null;
        }
        return sysUser;
    }


    /**
     *
     * 功能描述: 获取User
     *
     * @param:
     * @return:
     * @auther: Administrator
     * @date: 2020/3/10 14:36
     */
    public static LoginUser getUserInfoByToken(String token) {
        LoginUser sysUser = null;
        try {
            sysUser = SecurityUtils.getSubject().getPrincipal() != null ? (LoginUser) SecurityUtils.getSubject().getPrincipal() : null;
        } catch (Exception e) {
            //e.printStackTrace();
            sysUser = null;
        }
        return sysUser;
    }



}
